package com.taoyi.mhouse.fragments;

import android.nfc.Tag;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

/**
 * Created by tempo on 2015/11/12.
 */
public class BaseFragment extends Fragment {
    private static final String TAG="BaseFragment";
    protected enum FragmentState{
       OnCreate, OnCreateView,OnResume,OnDestroy,EMPTY
    }
    protected FragmentState fragmentState=FragmentState.EMPTY;
    @Override
    public void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        showTag("onCreate");
        fragmentState=FragmentState.OnCreate;
    }

    @Override
    public void onActivityCreated(@Nullable Bundle savedInstanceState) {
        super.onActivityCreated(savedInstanceState);
        showTag("onActivityCreated");
    }

    @Nullable
    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
        showTag("onCreateView,bundle="+savedInstanceState);
        fragmentState=FragmentState.OnCreateView;
        return super.onCreateView(inflater, container, savedInstanceState);
    }

    @Override
    public void onResume() {
        showTag("onResume");
        fragmentState=FragmentState.OnResume;
        super.onResume();
    }

    @Override
    public void onStop() {
        super.onStop();
        showTag("onStop");
    }

    @Override
    public void onDestroy() {
        super.onDestroy();
        fragmentState=FragmentState.OnDestroy;
        showTag("onDestroy");
    }
    public boolean isShowLog()
    {
        return false;
    }
    public void showTag(String life){
        if(isShowLog()){
            Log.i(TAG,this.getClass().getSimpleName()+":"+life);
        }

    }
}
